home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '90 / Utilities ƒ / MPW Tools ƒ / Simula4.07 / Simula 4.07ƒ / SInterfaces / macProcess.sim < prev    next >
Encoding:
Text File  |  1989-05-01  |  2.8 KB  |  76 lines  |  [TEXT/MPS ]

  1. % ---------------------------------------------------------------------------
  2. %    Class MACProcess
  3. % Part of the Lund Software interface to Macintosh Toolbox
  4. % MACProcess is part of the programming interface. 
  5. % Processes are used to capture events that are directed to
  6. % a window. The MACProcessMGR are receiving the events from the
  7. % Mac and distributes them to the concerned window.
  8. % For each Window - create also a MACProcess and hook it to the window
  9. % by calling ControllingWindow in MACProcessMGR.
  10. %
  11. % 890406/Boris Magnusson
  12. %
  13. % ---------------------------------------------------------------------------
  14. External class MacEvent="::SInterfaces:MacEvent";
  15. External class MacUtilities="::SInterfaces:MacUtilities";
  16. External class MacToolConst="::SInterfaces:MacToolConst";
  17. class MACProcess;
  18. virtual: ! -- called from procmgr to signal special "events": ;
  19.     procedure doGoAway is procedure doGoAway;;
  20.     procedure doSize is 
  21.         procedure doSize(v,h); integer v,h;;
  22. begin
  23.     ref(macUtilities) Util; ! To access toolbox general utils;
  24.     ref(macToolConst) TConst;! To access Tool-constants ;
  25.                                     ! Both assigned by procmgr at start-time;
  26. !-----------------------------  Attributes known by processmgr - ;                                    
  27. ! --- Used as detach/call "parameters". --- ;
  28.     ref(MacEvent) CurrentEvent;  ! -- refers to System event record;
  29.     integer CurrentFindresult;
  30.     Boolean WaitingForEvent;    ! True to signal idle to procmgr;
  31.     short integer CurrentMask; ! Holds mask for accepted Event cods;
  32.     boolean Terminate;            ! Set to true when process is dying.;
  33. !-----------------------------;    
  34. ! Two procedures to manipulate the CurrentMask, they take a 
  35. ! Eventcode (0,1,,15) as defined in macToolConst. 
  36. ! sets/clears corresponding bit in CurrentMask.
  37. ! * EnableEvent(TConst.EveryEvent) enables all events.
  38. ! * DisableEvent(TConst.EveryEvent) disables all events .
  39. ;
  40.     procedure EnableEvent(EventCode); short integer EventCode;
  41.     begin
  42.         if EventCode=TCONST.everyEvent then CurrentMask:=-1 !all bits;
  43.         else 
  44.             Currentmask:=Util.BitOr(
  45.                     Util.BitShift(1,EventCode) , CurrentMask );
  46.     end -- EnableEvent --;
  47.     
  48.     procedure DisableEvent(EventCode); short integer EventCode;
  49.     begin
  50.         if EventCode=TCONST.EveryEvent then CurrentMask:=0 ! no bits;
  51.         else
  52.             Currentmask:=Util.BitAnd(
  53.                     Util.BitNot(Util.BitShift(1,EventCode))  ,
  54.                     CurrentMask );
  55.     end --- DisableEvent --;
  56.  
  57.     ! Wait for an event targeted at my window. ;
  58.     integer procedure WaitNextEvent(theEvent); 
  59.         ref(MacEvent) theEvent;
  60.     begin
  61.         WaitingForEvent:=True;
  62.         detach;
  63.         CurrentEvent.copyevent(theEvent);
  64.         WaitNextEvent:=CurrentFindResult;
  65.     end --- Input ---;
  66.     
  67. ! --- dummy versions of virtual procedures --;
  68.     procedure doGoaway; ;
  69.     procedure doSize(v,h); integer v,h;;
  70.  
  71. ! -- Initialize / Terminate -- ;
  72.     Detach; ! do not do anything until activated !;
  73.     inner;
  74.     terminate:=true; !Taken out of queues when returning;
  75. end --- Mac Process --- ;